<template>
	<div id="app">
		<button @click="changeView('channel')">群聊示例</button>
		<button @click="changeView('one2one')">一对一示例</button>
		<component :is="current"></component>
		<!--
		<h3>群聊示例</h3>-->
		<!--server websocket服务器 channel订阅的频道（加入的群聊） -->
		<!--<client1 ref="c1" server="http://localhost:5000" channel="laoxiang" @onmessage="client1Onmessage"></client1>
		接收到数据：{{client1GetMsg}}从
		<client2 ref="c2" server="http://localhost:5000" channel="laoxiang" ></client2>-->
	
	</div>
</template>

<script>
import channel from './view/channel/index';
import one2one from './view/one2one/index';
export default {
	name: 'app',
	components: {
		one2one,
		channel
	},
	data() {
		return {
			current:'channel',
			client1GetMsg:""//客户端1收到的信息
		};
	},	
	methods: {
		client1Onmessage(data) {//客户端1收到消息的回调函数
			this.client1GetMsg=data;
		},
		changeView(v){
			this.current=v
		}
	},
	mounted() {
		var n=0,that=this
		//模拟客户端2发送消息
		setInterval(function(){
			n++
			//that.$refs.c2.SendChannelMsg("laoxiang", n)
		},1000)
		
	}
};
</script>

<style></style>
